﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Common
{
    public partial class SelectBuyPointDialog : UserControl, ISelectBuyPointDialogView
    {

        #region ISelectBuyPointDialogView Members

        public void SetBuyerList(System.Data.SqlServerCe.SqlCeDataReader buyers, string colName)
        {
            while (buyers.Read())
            {
                buyerComboBox.Items.Add(buyers); 
            }
            buyerComboBox.DisplayMember = colName;
        }

        public void SetBuyPointsList(System.Data.SqlServerCe.SqlCeDataReader buyPoint, string colName)
        {
            while (buyPoint.Read())
            {
                buyerComboBox.Items.Add(buyPoint);
            }
            buyerComboBox.DisplayMember = colName;
        }

        public object GetBuyerFilterValue
        {
            get { return buyerComboBox.SelectedItem; }
        }

        public string AdressBuyPoint
        {
            get { return adressLabel.Text; }
            set { adressLabel.Text = value; }

        }

        public object GetBuyerPointFilterValue
        {
            get { return buyPointComboBox.SelectedItem; }
        }

        public event EventHandler<EventArgs> SelectedBuyer;
        public event EventHandler<EventArgs> SelectedBuyPoint;

        #endregion

        public SelectBuyPointDialog()
        {
            InitializeComponent();
            new SelectBuyPointDialogPresenter(this);
        }

        private void buyerComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedBuyer(null, null);
            
        }

        private void buyPointComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SelectedBuyPoint(null, null);
        }
    }
}
